From 67d99a46d369a0d8d9684eda91760f1de5244dc5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 29 Apr 2025 12:51:13 +0800 Subject: [PATCH] feat(mac-crafter): Add ability to codesign with an entitlements file Signed-off-by: Claudio Cambra --- admin/osx/mac-crafter/Sources/Utils/Codesign.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/admin/osx/mac-crafter/Sources/Utils/Codesign.swift b/admin/osx/mac-crafter/Sources/Utils/Codesign.swift index 927133133..cd6046701 100644 --- a/admin/osx/mac-crafter/Sources/Utils/Codesign.swift +++ b/admin/osx/mac-crafter/Sources/Utils/Codesign.swift @@ -107,7 +107,9 @@ func saveCodesignEntitlements(target: String, path: String) throws { } func codesignClientAppBundle( - at clientAppDir: String, withCodeSignIdentity codeSignIdentity: String + at clientAppDir: String, + withCodeSignIdentity codeSignIdentity: String, + usingEntitlements entitlementsPath: String? = nil ) throws { print("Code-signing Nextcloud Desktop Client libraries, frameworks and plugins...") @@ -197,5 +199,13 @@ func codesignClientAppBundle( let mainExecutableName = String(appName.dropLast(".app".count)) let mainExecutablePath = "\(binariesDir)/\(mainExecutableName)" try recursivelyCodesign(path: binariesDir, identity: codeSignIdentity, skip: [mainExecutablePath]) - try codesign(identity: codeSignIdentity, path: mainExecutablePath) + + var mainExecutableCodesignOptions = defaultCodesignOptions + if let entitlementsPath { + mainExecutableCodesignOptions = + "--timestamp --force --verbose=4 --options runtime --entitlements \"\(entitlementsPath)\"" + } + try codesign( + identity: codeSignIdentity, path: mainExecutablePath, options: mainExecutableCodesignOptions + ) } -- 2.30.2